import * as rootController  from '@/api/forward'

const actions = {
  setSysConfig({ commit }) {
    var sysConfig = {}
    // 获取config 、warehouse、vendor 等接口数据合并成sysConfig
    rootController.getSysConfig()
      .then((res) => {
        sysConfig = res.dat
        rootController.getWarehouselist()
          .then((warehouse) => {
            sysConfig.warehouselist = warehouse.dat.data
            // 获取vendor
            rootController.getVendorlist().then(res => {
              sysConfig.vendorList = res.dat.data
              // console.log(sysConfig)
              commit('mutSysConfig', sysConfig)

            }).catch(err => { console.log(err) })
          }).catch((err) => {
            console.log(err)
          })
      }).catch((err) => {
        console.log(err)
      })
  }

};

export default actions;